{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JNSdeDvgpdng"
      },
      "source": [
        "# Notebook Setup\n",
        "<a target=\"_blank\" href=\"https://colab.research.google.com/github/PacktPublishing/Generative-AI-Integration-Patterns-1E/blob/main/Chapter06/Integration_pattern_batch_summarization.ipynb\">\n",
        "  <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
        "</a>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "nZzaJzUUoRbW"
      },
      "outputs": [],
      "source": [
        "#Install dependencies\n",
        "\n",
        "!pip install --upgrade google-cloud-aiplatform"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "euBE2B3DpHSQ"
      },
      "outputs": [],
      "source": [
        "#Authenticate\n",
        "!gcloud auth application-default login"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "IHRIcyzsoT6J"
      },
      "outputs": [],
      "source": [
        "import base64\n",
        "import vertexai\n",
        "from vertexai.generative_models import GenerativeModel, Part, FinishReason\n",
        "import vertexai.preview.generative_models as generative_models"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "id": "qgNuihpJqgkJ"
      },
      "outputs": [],
      "source": [
        "PROJECT = \"YOUR-GCP-PROJECT\"#@param {type:\"string\"}\n",
        "LOCATION = \"us-central1\"#@param {type:\"string\"}\n",
        "MODEL = \"gemini-1.5-pro-001\"#@param {type:\"string\"}"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "91JnL54jpkkE"
      },
      "source": [
        "# Function Definitions"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Ioi8N6nNp4xE"
      },
      "outputs": [],
      "source": [
        "generation_config = {\n",
        "    \"max_output_tokens\": 8192,\n",
        "    \"temperature\": 0,\n",
        "    \"top_p\": 0.95,\n",
        "}\n",
        "\n",
        "safety_settings = {\n",
        "    generative_models.HarmCategory.HARM_CATEGORY_HATE_SPEECH: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,\n",
        "    generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,\n",
        "    generative_models.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,\n",
        "    generative_models.HarmCategory.HARM_CATEGORY_HARASSMENT: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,\n",
        "}\n",
        "\n",
        "def generate(prompt_template_beggining,document,prompt_template_end):\n",
        "  vertexai.init(project=PROJECT, location=LOCATION)\n",
        "  model = GenerativeModel(MODEL)\n",
        "  responses = model.generate_content(\n",
        "      [prompt_template_beggining,document,prompt_template_end],\n",
        "      generation_config=generation_config,\n",
        "      safety_settings=safety_settings,\n",
        "      stream=False,\n",
        "  )\n",
        "  return(responses)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "B7rAfCnbs22H"
      },
      "source": [
        "# Entry Point"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "OeMoRv8itoCJ"
      },
      "outputs": [],
      "source": [
        "#@title Example signup forms\n",
        "JSON_DOC = \"\"\"\n",
        "[\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Tech Solutions Inc.\",\n",
        "            \"dba_name\": \"TechSol\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Technology\",\n",
        "            \"industry_description\": \"Software development and IT consulting services.\",\n",
        "            \"website\": \"https://www.techsolutions.com\",\n",
        "            \"date_founded\": \"2010-03-15\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 5000,\n",
        "            \"average_transaction_value\": 120,\n",
        "            \"business_model_description\": \"B2B software subscriptions and project-based consulting fees.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"John Smith\",\n",
        "                \"email\": \"john.smith@techsolutions.com\",\n",
        "                \"phone_number\": \"555-123-4567\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"123 Main St\",\n",
        "                \"city\": \"Anytown\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"91234\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"12-3456789\",\n",
        "            \"aml_kyc_policy\": \"We adhere to strict AML/KYC regulations and conduct thorough customer due diligence.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Acme Fintech Solutions Inc.\",\n",
        "            \"dba_name\": \"Acme Pay\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Financial Technology\",\n",
        "            \"industry_description\": \"Developing a mobile payment platform for peer-to-peer transactions.\",\n",
        "            \"website\": \"https://www.acmepay.com\",\n",
        "            \"date_founded\": \"2021-03-15\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 50000,\n",
        "            \"average_transaction_value\": 75,\n",
        "            \"business_model_description\": \"We charge a small fee on each transaction processed through our platform.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"John Smith\",\n",
        "                \"email\": \"john.smith@acmepay.com\",\n",
        "                \"phone_number\": \"555-123-4567\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"123 Main Street\",\n",
        "                \"city\": \"San Francisco\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"94105\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"12-3456789\",\n",
        "            \"aml_kyc_policy\": \"We have a robust AML/KYC policy in place, including identity verification and transaction monitoring.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Green Thumbs LLC\",\n",
        "            \"dba_name\": \"Green Thumbs\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"E-commerce\",\n",
        "            \"industry_description\": \"Online marketplace for CBD and hemp gardening supplies.\",\n",
        "            \"website\": \"https://www.greenthumbs.com\",\n",
        "            \"date_founded\": \"2022-08-01\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 2000,\n",
        "            \"average_transaction_value\": 120,\n",
        "            \"business_model_description\": \"We earn a commission on each sale made through our platform.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Jane Doe\",\n",
        "                \"email\": \"jane.doe@greenthumbs.com\",\n",
        "                \"phone_number\": \"555-234-5678\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"456 Oak Avenue\",\n",
        "                \"city\": \"Los Angeles\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"90001\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"98-7654321\",\n",
        "            \"aml_kyc_policy\": \"We comply with all applicable AML/KYC regulations.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Tech Gun Gear Inc.\",\n",
        "            \"dba_name\": \"Tech Gun Gear\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Retail\",\n",
        "            \"industry_description\": \"Retailer of guns, hand weapons and gadgets.\",\n",
        "            \"website\": \"https://www.techgear.com\",\n",
        "            \"date_founded\": \"2019-01-15\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 10000,\n",
        "            \"average_transaction_value\": 250,\n",
        "            \"business_model_description\": \"We sell firearms directly to consumers through our online store and physical locations.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Robert Lee\",\n",
        "                \"email\": \"robert.lee@techgear.com\",\n",
        "                \"phone_number\": \"555-345-6789\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"789 Pine Street\",\n",
        "                \"city\": \"New York\",\n",
        "                \"state\": \"NY\",\n",
        "                \"postal_code\": \"10001\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"55-6677889\",\n",
        "            \"aml_kyc_policy\": \"What is KYC?\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Travel Adventures LLC\",\n",
        "            \"dba_name\": \"Travel Adventures\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"Travel\",\n",
        "            \"industry_description\": \"Online travel booking platform for adventure travel experiences.\",\n",
        "            \"website\": \"https://www.traveladventures.com\",\n",
        "            \"date_founded\": \"2020-07-01\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 1500,\n",
        "            \"average_transaction_value\": 1500,\n",
        "            \"business_model_description\": \"We earn a commission on each travel booking made through our platform.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Maria Garcia\",\n",
        "                \"email\": \"maria.garcia@traveladventures.com\",\n",
        "                \"phone_number\": \"555-456-7890\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"312 Cedar Street\",\n",
        "                \"city\": \"Miami\",\n",
        "                \"state\": \"FL\",\n",
        "                \"postal_code\": \"33133\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"33-4455667\",\n",
        "            \"aml_kyc_policy\": \"We adhere to strict AML/KYC guidelines.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Creative Designs Inc.\",\n",
        "            \"dba_name\": \"Creative Designs\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Design Services\",\n",
        "            \"industry_description\": \"Providing graphic design and branding services to businesses.\",\n",
        "            \"website\": \"https://www.creativedesigns.com\",\n",
        "            \"date_founded\": \"2018-05-10\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 500,\n",
        "            \"average_transaction_value\": 5000,\n",
        "            \"business_model_description\": \"We offer design packages and hourly rates for our services.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"David Chen\",\n",
        "                \"email\": \"david.chen@creativedesigns.com\",\n",
        "                \"phone_number\": \"555-567-8901\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"214 Oakwood Lane\",\n",
        "                \"city\": \"Chicago\",\n",
        "                \"state\": \"IL\",\n",
        "                \"postal_code\": \"60606\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"22-3344556\",\n",
        "            \"aml_kyc_policy\": \"We have established AML/KYC procedures to ensure compliance.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Acme Robotics Inc.\",\n",
        "            \"dba_name\": \"Acme Robotics\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Robotics\",\n",
        "            \"industry_description\": \"Developing and manufacturing cutting-edge robotic solutions for industrial automation.\",\n",
        "            \"website\": \"https://www.acmerobotics.com\",\n",
        "            \"date_founded\": \"2018-03-15\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 500,\n",
        "            \"average_transaction_value\": 10000,\n",
        "            \"business_model_description\": \"We sell robots and provide maintenance services.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"John Smith\",\n",
        "                \"email\": \"john.smith@acmerobotics.com\",\n",
        "                \"phone_number\": \"+1-555-123-4567\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"123 Main St\",\n",
        "                \"city\": \"Anytown\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"91234\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"12-3456789\",\n",
        "            \"aml_kyc_policy\": \"We adhere to strict AML/KYC regulations and conduct thorough customer due diligence.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Green Thumb Farms LLC\",\n",
        "            \"dba_name\": \"Green Thumb Farms\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"Agriculture\",\n",
        "            \"industry_description\": \"Organic farming of fruits and vegetables for local markets and restaurants.\",\n",
        "            \"website\": \"https://www.greenthumbfarms.com\",\n",
        "            \"date_founded\": \"2015-07-22\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 200,\n",
        "            \"average_transaction_value\": 500,\n",
        "            \"business_model_description\": \"Direct-to-consumer sales through farmers markets and online orders, as well as wholesale to restaurants.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Jane Doe\",\n",
        "                \"email\": \"jane.doe@greenthumbfarms.com\",\n",
        "                \"phone_number\": \"+1-555-234-5678\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"456 Oak Ave\",\n",
        "                \"city\": \"Springfield\",\n",
        "                \"state\": \"IL\",\n",
        "                \"postal_code\": \"60652\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"98-7654321\",\n",
        "            \"aml_kyc_policy\": \"We comply with all applicable AML/KYC regulations and verify customer identities.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Creative Designs Co.\",\n",
        "            \"dba_name\": \"Creative Designs\",\n",
        "            \"company_type\": \"Partnership\",\n",
        "            \"industry\": \"Design Services\",\n",
        "            \"industry_description\": \"Providing graphic design, web design, and branding services to small businesses.\",\n",
        "            \"website\": \"https://www.creativedesigns.co\",\n",
        "            \"date_founded\": \"2020-01-10\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 100,\n",
        "            \"average_transaction_value\": 2500,\n",
        "            \"business_model_description\": \"Project-based work with upfront payments and recurring maintenance contracts.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"David Lee\",\n",
        "                \"email\": \"david.lee@creativedesigns.co\",\n",
        "                \"phone_number\": \"+1-555-345-6789\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"789 Pine St\",\n",
        "                \"city\": \"Denver\",\n",
        "                \"state\": \"CO\",\n",
        "                \"postal_code\": \"80202\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"56-7890123\",\n",
        "            \"aml_kyc_policy\": \"We follow industry best practices for AML/KYC compliance and customer verification.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Sunrise Coffee Shop\",\n",
        "            \"dba_name\": \"Sunrise Coffee\",\n",
        "            \"company_type\": \"Sole Proprietorship\",\n",
        "            \"industry\": \"Food & Beverage\",\n",
        "            \"industry_description\": \"Serving specialty coffee, pastries, and light breakfast and lunch options.\",\n",
        "            \"website\": \"https://www.sunrisecoffee.com\",\n",
        "            \"date_founded\": \"2022-09-05\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 1000,\n",
        "            \"average_transaction_value\": 15,\n",
        "            \"business_model_description\": \"Retail sales of coffee and food items with a focus on customer experience and community building.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Sarah Kim\",\n",
        "                \"email\": \"sarah.kim@sunrisecoffee.com\",\n",
        "                \"phone_number\": \"+1-555-456-7890\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"313 Maple Ave\",\n",
        "                \"city\": \"Austin\",\n",
        "                \"state\": \"TX\",\n",
        "                \"postal_code\": \"78701\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"45-6789012\",\n",
        "            \"aml_kyc_policy\": \"We comply with relevant AML/KYC regulations and have procedures for customer identification.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Travel Adventures Inc.\",\n",
        "            \"dba_name\": \"Travel Adventures\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Travel & Tourism\",\n",
        "            \"industry_description\": \"Providing customized travel planning and booking services for individuals and groups.\",\n",
        "            \"website\": \"https://www.traveladventures.com\",\n",
        "            \"date_founded\": \"2017-06-18\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 75,\n",
        "            \"average_transaction_value\": 5000,\n",
        "            \"business_model_description\": \"Fee-based travel planning and commission-based bookings of flights, accommodations, and activities.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Michael Chen\",\n",
        "                \"email\": \"michael.chen@traveladventures.com\",\n",
        "                \"phone_number\": \"+1-555-567-8901\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"202 Cedar St\",\n",
        "                \"city\": \"Seattle\",\n",
        "                \"state\": \"WA\",\n",
        "                \"postal_code\": \"98101\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"34-5678901\",\n",
        "            \"aml_kyc_policy\": \"We have robust AML/KYC policies in place to prevent financial crime and ensure compliance.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Tech Solutions Group LLC\",\n",
        "            \"dba_name\": \"Tech Solutions Group\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"Information Technology\",\n",
        "            \"industry_description\": \"Offering IT consulting, software development, and network management services.\",\n",
        "            \"website\": \"https://www.techsolutionsgroup.com\",\n",
        "            \"date_founded\": \"2016-04-25\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 300,\n",
        "            \"average_transaction_value\": 1000,\n",
        "            \"business_model_description\": \"Hourly consulting fees, project-based contracts, and managed service agreements.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Emily Wilson\",\n",
        "                \"email\": \"emily.wilson@techsolutionsgroup.com\",\n",
        "                \"phone_number\": \"+1-555-678-9012\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"999 Birch St\",\n",
        "                \"city\": \"San Francisco\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"94102\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"23-4567890\",\n",
        "            \"aml_kyc_policy\": \"We maintain strict adherence to AML/KYC regulations and perform thorough customer due diligence.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Healthy Habits Fitness Studio\",\n",
        "            \"dba_name\": \"Healthy Habits Fitness\",\n",
        "            \"company_type\": \"Sole Proprietorship\",\n",
        "            \"industry\": \"Health & Wellness\",\n",
        "            \"industry_description\": \"Providing fitness classes, personal training, and wellness programs.\",\n",
        "            \"website\": \"https://www.healthyhabitsfitness.com\",\n",
        "            \"date_founded\": \"2021-11-12\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 400,\n",
        "            \"average_transaction_value\": 100,\n",
        "            \"business_model_description\": \"Membership fees, class packages, and personal training sessions.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Daniel Garcia\",\n",
        "                \"email\": \"daniel.garcia@healthyhabitsfitness.com\",\n",
        "                \"phone_number\": \"+1-555-789-0123\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"525 Oakwood Ln\",\n",
        "                \"city\": \"Miami\",\n",
        "                \"state\": \"FL\",\n",
        "                \"postal_code\": \"33133\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"09-8765432\",\n",
        "            \"aml_kyc_policy\": \"We comply with applicable AML/KYC regulations and have procedures for customer identification and risk assessment.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Pet Care Services Ltd.\",\n",
        "            \"dba_name\": \"Pet Care Services\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Pet Services\",\n",
        "            \"industry_description\": \"Offering dog walking, pet sitting, and grooming services.\",\n",
        "            \"website\": \"https://www.petcareservices.com\",\n",
        "            \"date_founded\": \"2019-02-27\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 250,\n",
        "            \"average_transaction_value\": 50,\n",
        "            \"business_model_description\": \"Hourly rates for dog walking and pet sitting, and package pricing for grooming services.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Ashley Rodriguez\",\n",
        "                \"email\": \"ashley.rodriguez@petcareservices.com\",\n",
        "                \"phone_number\": \"+1-555-890-1234\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"616 Willow Rd\",\n",
        "                \"city\": \"Chicago\",\n",
        "                \"state\": \"IL\",\n",
        "                \"postal_code\": \"60606\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"87-6543210\",\n",
        "            \"aml_kyc_policy\": \"We adhere to relevant AML/KYC regulations and have a process for customer verification.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Home Improvement Solutions Co.\",\n",
        "            \"dba_name\": \"Home Improvement Solutions\",\n",
        "            \"company_type\": \"Partnership\",\n",
        "            \"industry\": \"Construction & Home Improvement\",\n",
        "            \"industry_description\": \"Providing home renovation, remodeling, and repair services.\",\n",
        "            \"website\": \"https://www.homeimprovementsolutions.com\",\n",
        "            \"date_founded\": \"2020-08-19\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 150,\n",
        "            \"average_transaction_value\": 7500,\n",
        "            \"business_model_description\": \"Project-based contracts with payment schedules tied to completion milestones.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Brian Williams\",\n",
        "                \"email\": \"brian.williams@homeimprovementsolutions.com\",\n",
        "                \"phone_number\": \"+1-555-901-2345\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"707 Pinewood Dr\",\n",
        "                \"city\": \"Atlanta\",\n",
        "                \"state\": \"GA\",\n",
        "                \"postal_code\": \"30303\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"76-5432109\",\n",
        "            \"aml_kyc_policy\": \"We comply with AML/KYC regulations and have procedures for customer identification and due diligence.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Fashion Boutique LLC\",\n",
        "            \"dba_name\": \"Fashion Boutique\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"Retail & Apparel\",\n",
        "            \"industry_description\": \"Selling trendy clothing, accessories, and footwear for women.\",\n",
        "            \"website\": \"https://www.fashionboutique.com\",\n",
        "            \"date_founded\": \"2023-03-08\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 600,\n",
        "            \"average_transaction_value\": 120,\n",
        "            \"business_model_description\": \"Retail sales through a physical store and online e-commerce platform.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Jessica Brown\",\n",
        "                \"email\": \"jessica.brown@fashionboutique.com\",\n",
        "                \"phone_number\": \"+1-555-012-3456\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"404 Oak St\",\n",
        "                \"city\": \"Los Angeles\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"90001\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"65-4321098\",\n",
        "            \"aml_kyc_policy\": \"We have established AML/KYC policies and procedures to mitigate financial crime risks.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Acme Financial Technologies Inc.\",\n",
        "            \"dba_name\": \"Acme FinTech\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Financial Technology\",\n",
        "            \"industry_description\": \"Develops payment processing software for e-commerce businesses.\",\n",
        "            \"website\": \"https://www.acmefintech.com\",\n",
        "            \"date_founded\": \"2019-04-01\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 10000,\n",
        "            \"average_transaction_value\": 50,\n",
        "            \"business_model_description\": \"Software as a Service (SaaS) model with monthly subscription fees based on transaction volume.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"John Smith\",\n",
        "                \"email\": \"john.smith@acmefintech.com\",\n",
        "                \"phone_number\": \"555-123-4567\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"123 Main St\",\n",
        "                \"city\": \"San Francisco\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"94105\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"12-3456789\",\n",
        "            \"aml_kyc_policy\": \"We have a robust AML/KYC policy that includes customer identity verification, transaction monitoring, and risk assessment.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Zenith Payments LLC\",\n",
        "            \"dba_name\": \"ZenithPay\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"Financial Services\",\n",
        "            \"industry_description\": \"Provides mobile payment solutions for small businesses.\",\n",
        "            \"website\": \"https://www.zenithpay.com\",\n",
        "            \"date_founded\": \"2021-08-15\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 5000,\n",
        "            \"average_transaction_value\": 20,\n",
        "            \"business_model_description\": \"Charges a per-transaction fee for payment processing.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Jane Doe\",\n",
        "                \"email\": \"jane.doe@zenithpay.com\",\n",
        "                \"phone_number\": \"555-234-5678\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"456 Oak Ave\",\n",
        "                \"city\": \"Los Angeles\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"90001\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"98-7654321\",\n",
        "            \"aml_kyc_policy\": \"We adhere to strict AML/KYC regulations and conduct thorough due diligence on all customers.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Nova Financial Group Inc.\",\n",
        "            \"dba_name\": \"NovaFin\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Investment Management\",\n",
        "            \"industry_description\": \"Offers robo-advisory services for automated investment portfolios.\",\n",
        "            \"website\": \"https://www.novafin.com\",\n",
        "            \"date_founded\": \"2017-03-10\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 2000,\n",
        "            \"average_transaction_value\": 1000,\n",
        "            \"business_model_description\": \"Charges a percentage fee based on assets under management.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Robert Lee\",\n",
        "                \"email\": \"robert.lee@novafin.com\",\n",
        "                \"phone_number\": \"555-345-6789\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"789 Pine St\",\n",
        "                \"city\": \"New York\",\n",
        "                \"state\": \"NY\",\n",
        "                \"postal_code\": \"10001\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"56-7890123\",\n",
        "            \"aml_kyc_policy\": \"We maintain a comprehensive AML/KYC program to prevent financial crimes and ensure regulatory compliance.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Quantum Solutions LLC\",\n",
        "            \"dba_name\": \"QuantumSol\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"Software Development\",\n",
        "            \"industry_description\": \"Develops custom software solutions for financial institutions.\",\n",
        "            \"website\": \"https://www.quantumsol.com\",\n",
        "            \"date_founded\": \"2020-06-22\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 500,\n",
        "            \"average_transaction_value\": 10000,\n",
        "            \"business_model_description\": \"Project-based billing for software development services.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Maria Garcia\",\n",
        "                \"email\": \"maria.garcia@quantumsol.com\",\n",
        "                \"phone_number\": \"555-456-7890\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"312 Cedar St\",\n",
        "                \"city\": \"Chicago\",\n",
        "                \"state\": \"IL\",\n",
        "                \"postal_code\": \"60606\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"45-6789012\",\n",
        "            \"aml_kyc_policy\": \"Our AML/KYC policy is designed to mitigate risks and comply with all applicable regulations.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Apex Capital Partners LLC\",\n",
        "            \"dba_name\": \"ApexCap\",\n",
        "            \"company_type\": \"LLC\",\n",
        "            \"industry\": \"Venture Capital\",\n",
        "            \"industry_description\": \"Invests in early-stage fintech startups.\",\n",
        "            \"website\": \"https://www.apexcap.com\",\n",
        "            \"date_founded\": \"2018-09-18\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 100,\n",
        "            \"average_transaction_value\": 500000,\n",
        "            \"business_model_description\": \"Invests capital in exchange for equity ownership in startups.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"David Kim\",\n",
        "                \"email\": \"david.kim@apexcap.com\",\n",
        "                \"phone_number\": \"555-567-8901\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"214 Birch St\",\n",
        "                \"city\": \"Boston\",\n",
        "                \"state\": \"MA\",\n",
        "                \"postal_code\": \"02110\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"34-5678901\",\n",
        "            \"aml_kyc_policy\": \"We have stringent AML/KYC procedures to verify the identity of investors and the source of funds.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Veritas Data Security Inc.\",\n",
        "            \"dba_name\": \"VeritasSec\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Cybersecurity\",\n",
        "            \"industry_description\": \"Provides data security solutions for financial institutions.\",\n",
        "            \"website\": \"https://www.veritassec.com\",\n",
        "            \"date_founded\": \"2016-02-05\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 200,\n",
        "            \"average_transaction_value\": 25000,\n",
        "            \"business_model_description\": \"Sells software licenses and provides security consulting services.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Linda Chen\",\n",
        "                \"email\": \"linda.chen@veritassec.com\",\n",
        "                \"phone_number\": \"555-678-9012\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"987 Oakwood Lane\",\n",
        "                \"city\": \"Austin\",\n",
        "                \"state\": \"TX\",\n",
        "                \"postal_code\": \"78701\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"23-4567890\",\n",
        "            \"aml_kyc_policy\": \"We comply with all relevant data security and privacy regulations.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Phoenix Insurance Group Inc.\",\n",
        "            \"dba_name\": \"PhoenixInsure\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Insurance\",\n",
        "            \"industry_description\": \"Offers insurance products for businesses and individuals.\",\n",
        "            \"website\": \"https://www.phoenixinsure.com\",\n",
        "            \"date_founded\": \"2015-07-12\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 1000,\n",
        "            \"average_transaction_value\": 1500,\n",
        "            \"business_model_description\": \"Collects premiums and pays out claims.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Michael Brown\",\n",
        "                \"email\": \"michael.brown@phoenixinsure.com\",\n",
        "                \"phone_number\": \"555-789-0123\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"654 Maple St\",\n",
        "                \"city\": \"Seattle\",\n",
        "                \"state\": \"WA\",\n",
        "                \"postal_code\": \"98101\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"09-8765432\",\n",
        "            \"aml_kyc_policy\": \"We have a comprehensive AML/KYC program to prevent fraud and money laundering.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Global Payment Solutions Ltd.\",\n",
        "            \"dba_name\": \"GlobalPay\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Financial Technology\",\n",
        "            \"industry_description\": \"Provides cross-border payment processing services.\",\n",
        "            \"website\": \"https://www.globalpay.com\",\n",
        "            \"date_founded\": \"2014-11-25\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 5000,\n",
        "            \"average_transaction_value\": 1000,\n",
        "            \"business_model_description\": \"Charges a fee for currency exchange and international payment processing.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Emily Wilson\",\n",
        "                \"email\": \"emily.wilson@globalpay.com\",\n",
        "                \"phone_number\": \"555-890-1234\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"321 Pinewood Ave\",\n",
        "                \"city\": \"London\",\n",
        "                \"state\": \"\",\n",
        "                \"postal_code\": \"EC1A 1AA\",\n",
        "                \"country\": \"UK\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"GB123456789\",\n",
        "            \"aml_kyc_policy\": \"We follow strict AML/KYC protocols to comply with international regulations.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"Blockchain Technologies Corp.\",\n",
        "            \"dba_name\": \"BlockTech\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Blockchain\",\n",
        "            \"industry_description\": \"Develops blockchain-based solutions for financial services.\",\n",
        "            \"website\": \"https://www.blocktech.com\",\n",
        "            \"date_founded\": \"2022-01-19\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 1000,\n",
        "            \"average_transaction_value\": 500,\n",
        "            \"business_model_description\": \"Provides blockchain development and consulting services.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Daniel Rodriguez\",\n",
        "                \"email\": \"daniel.rodriguez@blocktech.com\",\n",
        "                \"phone_number\": \"555-901-2345\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"1010 Blockchain Blvd\",\n",
        "                \"city\": \"Miami\",\n",
        "                \"state\": \"FL\",\n",
        "                \"postal_code\": \"33131\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"78-9012345\",\n",
        "            \"aml_kyc_policy\": \"We are committed to building secure and compliant blockchain solutions.\"\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"company_information\": {\n",
        "            \"legal_name\": \"AI Finance Solutions Inc.\",\n",
        "            \"dba_name\": \"AIFin\",\n",
        "            \"company_type\": \"Corporation\",\n",
        "            \"industry\": \"Artificial Intelligence\",\n",
        "            \"industry_description\": \"Develops AI-powered financial forecasting tools.\",\n",
        "            \"website\": \"https://www.aifin.com\",\n",
        "            \"date_founded\": \"2023-05-08\"\n",
        "        },\n",
        "        \"business_details\": {\n",
        "            \"expected_transaction_volume\": 500,\n",
        "            \"average_transaction_value\": 2000,\n",
        "            \"business_model_description\": \"Subscription-based access to AI financial forecasting software.\"\n",
        "        },\n",
        "        \"contact_information\": {\n",
        "            \"primary_contact\": {\n",
        "                \"name\": \"Sophia Patel\",\n",
        "                \"email\": \"sophia.patel@aifin.com\",\n",
        "                \"phone_number\": \"555-012-3456\"\n",
        "            },\n",
        "            \"business_address\": {\n",
        "                \"street_address\": \"404 Not Found Ave\",\n",
        "                \"city\": \"Palo Alto\",\n",
        "                \"state\": \"CA\",\n",
        "                \"postal_code\": \"94301\",\n",
        "                \"country\": \"USA\"\n",
        "            }\n",
        "        },\n",
        "        \"compliance_information\": {\n",
        "            \"ein\": \"67-8901234\",\n",
        "            \"aml_kyc_policy\": \"We use AI to enhance our AML/KYC capabilities and ensure compliance.\"\n",
        "        }\n",
        "    }\n",
        "]\n",
        "\"\"\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "pg1e3tGBwgJ1"
      },
      "outputs": [],
      "source": [
        "#Load each entry into an array\n",
        "import json\n",
        "docs = []\n",
        "loaded_json = json.loads(JSON_DOC)\n",
        "for doc in loaded_json:\n",
        "  docs.append(doc)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "6bVKm_TkG4Q0"
      },
      "outputs": [],
      "source": [
        "#Verify the docs are a loaded\n",
        "print(docs[0])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ihAHrCBas5eW"
      },
      "source": [
        "# Prompt Preprocessing"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "YkAR047_r6jL"
      },
      "outputs": [],
      "source": [
        "#In this section we define the prompt, notice that the document will be included as part of the format\n",
        "prompt_template_beggining = \"\"\"\n",
        "You are an expert compliance analyst.\n",
        "\n",
        "Your task is to extract information from the sign up forms obtained.\n",
        "\n",
        "1. Carefully analyze the document provided as context.\n",
        "2. Write an intro paragraph for the company so the senior compliance analyst can quickly understand who the customer is.\n",
        "3. Following the guidance for approved businesses add a paragraph after the intro explaining why the business is supportable or not.\n",
        "4. Add another paragraph below explaining where the company is.\n",
        "5. Always think step by step.\n",
        "\n",
        "<supportable_businesses>\n",
        "Summary of Prohibited & Restricted Businesses\n",
        "\n",
        "This document outlines the types of businesses and activities that are generally not allowed or require prior approval to use payment processing services. These restrictions exist due to legal requirements, financial partner rules, and compliance and risk management policies of payment processors.\n",
        "\n",
        "Types of Businesses:\n",
        "\n",
        "High-Risk Jurisdictions and Persons: Businesses operating in or dealing with sanctioned countries and individuals.\n",
        "Prohibited Businesses: Activities involving illegal products or services, adult content, certain financial services, marijuana, unfair practices, weapons, etc.\n",
        "Restricted Businesses: Activities requiring prior written approval from the payment processor, such as CBD, financial products, pharmaceuticals, non-fiat currency, and more.\n",
        "Jurisdiction-Specific Prohibited Businesses: Additional restrictions based on specific countries, such as India, Japan, Malaysia, Mexico, Singapore, Thailand, UAE, and the US.\n",
        "\n",
        "Prohibited Uses of Payment Processing Services:\n",
        "\n",
        "Misrepresentation of identity or business.\n",
        "Facilitating transactions for undisclosed merchants.\n",
        "Using the service as a virtual terminal.\n",
        "Processing without actual goods or services.\n",
        "Evasion of chargeback monitoring.\n",
        "Sharing cardholder information.\n",
        "Misuse of intellectual property.\n",
        "\n",
        "Prohibitions for Card Issuing Products:\n",
        "Consumer use for personal expenses.\n",
        "International use outside of the registered jurisdiction.\n",
        "Lending without proper licensing and approval.\n",
        "Abusive practices like free trial abuse and scalping.\n",
        "Non-compliance with marketing and user experience guidelines.\n",
        "Inactivity for 12 consecutive months.\n",
        "Incorrect integration type for employee/contractor cards.\n",
        "\n",
        "Business Analyst Recommendations:\n",
        "Based on this information, a business analyst should pay close attention to the following types of businesses:\n",
        "Financial Services: This is a broad category with many restrictions and nuances. It's crucial to understand the specific requirements for lending, crowdfunding, money transmission, etc.\n",
        "Regulated Industries: Industries like CBD, pharmaceuticals, and tobacco require careful consideration of compliance and legal aspects.\n",
        "High-Risk Businesses: Businesses prone to fraud or abuse, like travel reservation services and multi-level marketing, need thorough risk assessments.\n",
        "Emerging Technologies: Activities involving cryptocurrency, NFTs, and other new technologies should be evaluated based on current regulations and the payment processor's policies.\n",
        "Jurisdiction-Specific Restrictions: Businesses operating in or targeting specific countries need to be aware of additional prohibitions and requirements.\n",
        "Additional Considerations:\n",
        "Business Model: Restrictions often depend on the specific business model and how the service is used.\n",
        "Compliance: Understanding and adhering to relevant regulations is essential to avoid account closure or other consequences.\n",
        "Risk Management: Businesses should have robust risk management practices to mitigate potential financial and legal risks.\n",
        "Transparency: Maintaining clear and accurate information about the business and its activities is crucial for approval and continued use of payment processing services.\n",
        "By carefully considering these factors, a business analyst can help ensure that businesses comply with the payment processor's policies and operate successfully within the platform.\n",
        "</supportable_businesses>\n",
        "<document>\n",
        "\"\"\"\n",
        "prompt_template_end=\"\"\"\n",
        "</document>\n",
        "\n",
        "Response:\n",
        "\n",
        "\"\"\""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LuJusiKDs7Au"
      },
      "source": [
        "# Inference"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "N_YWvX5lhHZV"
      },
      "outputs": [],
      "source": [
        "import time\n",
        "\n",
        "summaries = []\n",
        "for doc in docs:\n",
        "  result = generate(prompt_template_beggining,str(doc),prompt_template_end)\n",
        "  #sleep 10 seconds to not exceed 6 QPM\n",
        "  time.sleep(10)\n",
        "  summaries.append(result.text)\n",
        "  print(result.text)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fnSrhoN1tACl"
      },
      "source": [
        "# Result Postprocessing"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "ggiDKZp3292w"
      },
      "outputs": [],
      "source": [
        "#In this section we will add the summaries to the original documents, afterwards the results can be stored in a database.\n",
        "\n",
        "for  counter, doc in enumerate(docs):\n",
        "  doc['summary'] = summaries[counter]\n",
        "\n",
        "print(docs)"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
